Skip to content

Feature/scheduler#7

Open
kirkone wants to merge 3 commits into
masterfrom
feature/scheduler
Open

Feature/scheduler#7
kirkone wants to merge 3 commits into
masterfrom
feature/scheduler

Conversation

@kirkone
Copy link
Copy Markdown
Owner

@kirkone kirkone commented Aug 12, 2019

Addin task on runtime will be possible with this PR

this should close #2 #5

kirkone and others added 2 commits August 10, 2019 00:02
- Add a Scheduler to get access to the task list
- Refactor service registration
- Remove old sample
- Add new sample
- Add EditorConfig
- Add Possibility to add Task at Runtime

+semver: major
- Cancel Delay in Hosted Service done right 🤔

Co-authored-by: Paule <Paul-Jeschke@outlook.com>
@paule96 paule96 added this to the 2.0.0 milestone Aug 12, 2019
@paule96 paule96 added the enhancement New feature or request label Aug 12, 2019
Copy link
Copy Markdown
Collaborator

@paule96 paule96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

working branche

@kirkone
Copy link
Copy Markdown
Owner Author

kirkone commented Aug 12, 2019

Maybe @jphilipps has time for a review? 😁

_ = stoppingToken.Register(() => this.logger.LogDebug("Runtime Sample Task forced stopping."));

var runCount = 0;
while (runCount < 5)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I'd prefer a for-loop, but i assume thats a matter of style.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I will change this.


public class IndexModel : PageModel
{
private readonly ILogger<RuntimeSampleTask> runtimeSampleTaskLogger;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also matter of preference but: since almost all classes only have one logger, I call them all the same: "logger". I only call them differently if there are different loggers in a given class to make myself and others aware that this might not be the logger one wants to use. Also, the shorter name might allow you to put the parameters in lines 22ff on a single line.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, I will change that.


public void AddTask(IScheduledTask scheduledTask)
{
var taskName = string.IsNullOrWhiteSpace(scheduledTask.Options.Name) ? Guid.NewGuid().ToString() : scheduledTask.Options.Name;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many other lines have been broken before (which I think is optional), but in this case I guess it makes a lot of sense:

var taskName = string.IsNullOrWhiteSpace(scheduledTask.Options.Name) 
                  ? Guid.NewGuid().ToString() 
                  : scheduledTask.Options.Name;

@jphilipps
Copy link
Copy Markdown

Maybe @jphilipps has time for a review? 😁

Of cause, I’ll take a look as soon as I can.

Comment thread global.json
{
"sdk": {
"version": "2.2.105"
"version": "2.2.401"
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to newest version

ProjectFolder: "$(Build.SourcesDirectory)/src/KK.DotNet.BackgroundTasks.Scheduled"
DotNetVersion: "2.2.105"
GitVersion: "4.0.1-beta1-62"
DotNetVersion: "2.2.401"
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the new SDK from global.json

_ = stoppingToken.Register(() => this.logger.LogDebug("Runtime Sample Task forced stopping."));

var runCount = 0;
while (runCount < 5)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I will change this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

how to add/queue a new task

4 participants